import { parseString } from 'xml2js';
import { IsMock } from '../constants';

export async function fetchFullName(symbol: string): Promise<string | null > {
    try {

      if(IsMock) {
        return new Promise((res) => res('testFullName'))
      }

      const response = await fetch(`https://iss.moex.com/iss/engines/stock/markets/shares/securities/${symbol}.json`);
      const data = await response.json()

      return data.securities.data[0][2]
    } catch (error) {
      console.error('Error fetching data:', error);
      return null;
    }
  }
  